package com.ybkj.daijia.server.service;

import com.ybkj.daijia.common.PageVo;
import com.ybkj.daijia.page.Page;
import com.ybkj.daijia.server.model.Driver;
import com.ybkj.daijia.server.model.DriverLoginRecord;
import com.ybkj.daijia.server.model.DriverPaymentsRecord;
import com.ybkj.daijia.server.model.DriverRebatePaymentRecord;
import com.ybkj.daijia.server.model.PayRecordDriver;
import com.ybkj.daijia.server.model.PhoneRecord;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;

/**
 * @author Shine
 */
public interface DriverService {

    /**
     * 根据自定义参数查询驾驶员
     * @param driverName
     * @param driverPhone
     * @return
     */
    List<Driver> queryDriverByParams(String driverPhone, String driverName);

    void updateDriverTxAndTg(Driver driver);

    /**
     * 查询username最大的司机
     *
     * @return
     */
    String findLastestDriver();

    public Page<Driver> queryAll(String name, Integer status, Integer type);

    /**
     * 新增司机信息
     *
     * @param driver
     * @return
     */
    public Driver insertRecord(Driver driver);

    public int insertList(List<Driver> list);

    /**
     * 根据主键更新司机基本信息
     *
     * @param record
     * @return
     */
    public int updateByPrimaryKey(Driver record);


    /**
     * 根据主键更新司机基本信息
     *
     * @param record
     * @param basePath
     * @param carNumber
     * @return
     */
    public int updateInfo(Driver record, String basePath, String carNumber);


    /**
     * 根据主键更新司机推送信息
     *
     * @param record
     * @return
     */
    public int updatePushByPrimaryKey(Driver driver);

    /**
     * 根据主键查询司机信息
     *
     * @param id
     * @return
     */
    public Driver findOne(Long id);

    /**
     * 根据用户名查询出管理员信息
     *
     * @param username
     * @return
     */
    public Driver findByUsername(String username);

    public Driver findByCarId(Long carId);

    /**
     * 根据一组ID查询出管理员信息
     *
     * @param ids
     * @return
     */
    public List<Driver> findByIdIn(Long[] ids);

    /**
     * 删除管理信息
     *
     * @param basePath
     * @param admin
     */
    public void delete(Driver driver, String basePath);

    public List<Driver> listRealTime(Long orderId);

    /**
     * 查询经纬度50公里范围内的司机
     *
     * @param longitude
     * @param latitude
     * @return
     */
    public List<Driver> listdistance(Double longitude, Double latitude, String driverJobType);

    public List<Driver> listdiaodutuijian(Double longitude, Double latitude, Long orderId);

    public Page<Driver> queryLessList(String name);

    public Page<Driver> queryFreezeList(String name);

    public Page<PhoneRecord> queryRecordlist(String name);

    /**
     * 根据身份证查询司机
     *
     * @param username
     * @return
     */
    public Driver findByIdCard(String idCard);

    /**
     * 根据手机号查询司机
     *
     * @param username
     * @return
     */
    public Driver findByPhone(String phone);

    /**
     * 查询本公司（全部）司机（未冻结）
     *
     * @param username
     * @return
     */
    public List<Driver> listByCompany();

    /**
     * 分页查询附近的司机
     *
     * @param longitude
     * @param latitude
     * @param page
     * @param limit
     * @return
     */
    public PageVo<Driver> queryNearDrivers(Double longitude, Double latitude,
        Integer page, Integer limit);

    /**
     * 客户查看附近司机
     *
     * @param username
     * @return
     */
    public List<Driver> queryNearDrivers(Double longitude, Double latitude, String serviceType);

    /**
     * 微信客户查看附近司机
     *
     * @param username
     * @return
     */
    public List<Driver> wxQueryDriver(Double longitude, Double latitude, Integer type);

    /**
     * 司机查看附近司机
     *
     * @param username
     * @return
     */
    public List<Driver> queryNearDrivers2(Long driverId, Double longitude, Double latitude);

    /**
     * 更新channelID userID
     *
     * @param driverId
     * @return
     */
    public void updateDevice(String channelID, String userID);

    public List<Driver> selectByStatus(int status);

    public long countByStatus(int status);

    public long countAllLess();

    /**
     * 根据设备号查询司机
     *
     * @param udid
     * @return
     */
    public List<Driver> findByUdid(String udid);

    public Driver poweroffline(Long id);

    public void jiebang(Long id);

    public void audit(Driver driver, Long applyId);

    public List<Driver> listmodeDrivers();

    /**
     * 查询所有司机
     *
     * @return
     */
    public List<Driver> findAll();

    public List<Driver> findAllByCompanyId(Long companyId);

    public List<Driver> queryWorkCarPaidan(Long companyID, Long driverID);

    public Page<Driver> queryZhuandanEmploys(Long companyId, Long employId, Integer page,
        Integer limie);

    /**
     * 查询指定范围内的司机
     *
     * @param centerlng
     * @param centerlat
     * @param paidanKm
     * @return
     */
    public List<Driver> queryNearly(Double centerlng, Double centerlat, Double paidanKm,
        String driverJobType);

    public List<Driver> queryPaidanTuijian(Double orderlng, Double orderlat, Double paidanKm);

    /**
     * 根据用户输入的关键字 查询 匹配的 姓名、手机号、工号
     *
     * @param keyword
     * @return
     */
    public List<Driver> queryByKeyword(String keyword);

    /**
     * 查询所有上线的司机
     *
     * @return
     */
    public List<Driver> listValid(Long companyId);

    public void cashRecharge(PayRecordDriver payRecordDriver, String trade_no);

    /**
     * 更新数据库中司机位置信息
     *
     * @param longitude
     * @param latitude
     * @param lastlongitude
     * @param lastlatitude
     * @param currentAddress
     * @param driverId
     */
    public void updateLocation(Double longitude, Double latitude,
        Double lastlongitude, Double lastlatitude, String currentAddress,
        Long driverId);

    public void updatePosUpdated(Long driverId, Date posUpdated);

    public void money(Long driverid, DriverPaymentsRecord driverPaymentsRecord, String memo);

    /**
     * 司机上线
     *
     * @param driver
     */
    public void online(Driver driver);

    public List<Driver> findByTypeAndFreeze(String type, boolean isFreeze,
        Long companyId);

    public List<Driver> findByFreeze(boolean isFreeze, Long companyId);

    public List<Driver> findByVirtualAndFreeze(BigDecimal lowMoney,
        boolean isFreeze, Long companyId);

    public List<Driver> findAllByFreeze(boolean isFreeze, Long companyId);


    public List<Driver> findDriver(String param);


    /**
     * 重置所有司机日单量
     *
     * @return
     */
    public int clearDayOrderNums();


    /**
     * 重置所有司机月单量
     *
     * @return
     */
    public int clearMonthOrderNums();

    /**
     * 修改司机密码
     *
     * @param base64
     * @param id
     * @return
     */
    public int updateByPassword(String base64, Long id);

    /**
     * 修改司机状态
     *
     * @param status
     * @param
     * @return
     */
    public int updateStatus(int status, Long driverId);

    public int updateStatusAndJobStatus(int status, Integer jobStatus, Long driverId);

    public void updateVirtual(Driver driver);

    public List<Driver> listErrandDrivers(Long orderId);

    public List<Driver> findByParamLike(String param, Long companyId);

    public List<Driver> daijiaListDrivers(Double lng, Double lat, Double distance);

    /**
     * 根据距离查询在线空闲司机, 在更具carTypeId过滤司机, 最后根据收藏和距离排序
     *
     * @param lng
     * @param lat
     * @param distance
     * @param passengerId
     * @param carTypeId
     * @return
     */
    public List<Driver> zhuanListDrivers(Double lng, Double lat, Double distance, Long passengerId,
        Long carTypeId);

    public List<Driver> listDiaoduv3(boolean loadLixian);

    public long countDiaoduLixian();

    public List<Driver> tuijianDiaoduDrivers(Long orderId, String orderType);

    public List<Driver> queryDiaoduDrivers(String keyword, Long orderId, String orderType);


    public Page<Map<String, Object>> driverlistData(String name,
        String phone, String username, Date start, Date end, Long[] companyId, BigDecimal virtual,
        Boolean isFreeze, String[] type, Integer[] status, Integer[] isPlatform,
        Boolean isLeague);

    public List<Driver> freightListDrivers(Double lng, Double lat, Double distance);

    List<Driver> queryNearFreightDrivers(Double longitude, Double latitude);

    public List<Driver> selectDriverList(String name, String phone, String username, Date start,
        Date end,
        Long[] companyId, BigDecimal virtual, Boolean isFreeze, String[] type, Integer[] status,
        Integer[] isPlatform, String[] jobType);

    public List<Driver> errandListDrivers(Double lng, Double lat, Double distance);

    public List<Driver> zhuanxianListDrivers(Double lng, Double lat, Double distance);

    public Map<String, Object> login(Driver driver);

    public int updateGrad2NullByGrade(Long id);

    public List<Driver> findByZhuanxianCars(List<Long> carIds);

    public Long countById(Long employId);


    public Map<String, Object> checkDriver(Long[] ids, HttpSession session, String basePath);

    public void uploadDriver(Long[] ids, String basePath);

    public void updateDriverCarId(Long id, Long carId);

    public Page<DriverLoginRecord> loginListData(String param, Long[] companyId);

    /**
     * 司机端获取短信验证码
     *
     * @param phone
     * @param driver
     * @return
     */
    public Map<String, Object> getCodeV3(String phone, Driver driver);

    public void updateRebateMoney(BigDecimal money, Long id);

    public void changeMoneyByDriverPaymenrecord(DriverPaymentsRecord driverPaymentsRecord);

    public void changeMoneyByDriverRebatePaymenrecord(
        DriverRebatePaymentRecord driverRebatePaymentRecord);

    public int updateColumnsIfNotNull(Driver driver);
}
